@extends('cimo_admin.app')

@section('content')
<link href="{{ asset('/css/spinners.css') }}" rel="stylesheet">
<div id="grid" class="grid" style="position: fixed;z-index: 1000;left:50%;display: none;">
    <div class="cell">
        <div class="card">
            <span class="throbber-loader">Loading…</span>
        </div>
    </div>
</div>
<div class="loading" style=" font-size:20px;text-align:center;display:none;">
    <i class="icon-spinner icon-spin orange bigger-125"></i>
</div>
<ul class="nav nav-tabs">
    <li class="active"><a href="{{ url('/admin/refuel/stores/index')}}">店铺列表</a></li>
    {{--<li><a href="{{ url('/admin/enterprise/companys/create') }}">信息添加</a></li>--}}
</ul>

<div class="panel panel-info mt20">
    <div class="panel-heading">筛选</div>
    <div class="panel-body">
        <form action="" method="get" class="form-horizontal" role="form" id="form1">
            <div class="input-group">
                <div class="input-group-addon">公司名称</div>
                <input class="form-control" name="name" type="text" value="{{$name}}" placeholder="店铺名称">
               {{-- <div class="input-group-addon">企业用户</div>
                <input class="form-control" name="username" type="text" value="{{$username}}" placeholder="作者名称">--}}
                {{--<div class="input-group-addon">审核状态</div>
                <select name="is_verified" class="form-control">
                    <option value="-1">全部</option>
                    @foreach($verystatus as $k=>$tp)
                    <option value="{{$k}}" @if( $is_verified == $k) selected @endif>{{$tp}}</option>
                    @endforeach
                </select>--}}
            </div>
            <div class="form-group mt10">
                <div class="col-md-1 col-xs-12">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="panel panel-default mt20">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
          <thead>
            <tr>
              <th>编号</th>
              <th>公司名称</th>
              <th>公司口号</th>
                <th>公司状态</th>
              <th>创建时间</th>
              <th>到期时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
          @foreach($coms as $res)
            <tr id="news_{{ $res->id }}">
              <td>{{ $res->id }}</td>
                <td>{{ $res->name }}</td>
                <td>{{ $res->slogan }}</td>
                <td id="is_stop{{$res->id}}">
                    @if($res->status == 1)
                        <span class="glyphicon glyphicon-ok-circle  green-remove" onclick="changeStatus('/cimo/change-status','{{ $res->id }}', '2', '{{ csrf_token() }}');"></span>
                    @else
                        <span  class="glyphicon glyphicon-remove-circle red-ok" onclick="changeStatus('/cimo/change-status','{{ $res->id }}', '1', '{{ csrf_token() }}');"></span>
                    @endif
                </td>
              <td>{{ date('Y-m-d',strtotime($res->created_at))}}</td>
                <td>
                    {{ $res->expire_at}}
                </td>
              <td>
                <a href="{{ url('/cimo/memberlist?comid='.$res->id) }}">成员列表</a>
              </td>
            </tr>
          @endforeach
          </tbody>
        </table>
    </div>
</div>
<div>{!! $coms->render() !!} </div>
<script>
    function changeStatus(url,id,val,token)
    {
        //$('#is_stop').css('display', '');
        var datastr = 'id=' + id + '&status=' +val;
        $.ajax({
            'url':url,
            'type':'POST',
            'data':datastr+'&_token='+ token,
            success: function(data){
                if(data.status == 'success'){
                    if(data.data == 1){
                        $('#is_stop'+id+' span').attr('class', 'glyphicon glyphicon-ok-circle  green-remove');
                        $('#is_stop'+id+' span').attr('onclick',"changeStatus('"+url+"','"+id+"','"+'2'+"','"+token+"')");
                    }
                    else{
                        $('#is_stop'+id+' span').attr('class', 'glyphicon glyphicon-remove-circle red-ok');
                        $('#is_stop'+id+' span').attr('onclick',"changeStatus('"+url+"',"+id+","+'1'+",'"+token+"')");
                    }
                    //$('#is-stop').css('display', 'none');
                }

            }
        });
    }
</script>
@endsection
